﻿using Api.WDS.Methods;
using Method.DAL;
using Models.operResult;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Api.WDS.Operate
{
    public class InteractiveOp
    {
        /// <summary>
        /// 文章点赞
        /// </summary>
        /// <param name="token"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public OperResult<bool> ArticleLike(string token,string articleId) {
            var uid = new GetUidByToken().GetUid(token);
            if (uid is null)
                return OperResult<bool>.Failed("请重新登录");
            if(!int.TryParse(articleId,out int i))
                return OperResult<bool>.Failed("文章获取失败");

            switch (new InteractiveMet().ArticleLike(Convert.ToInt32(uid), Convert.ToInt32(articleId))) {
                case 1:
                    return OperResult<bool>.Succeed(true);
                case 2:
                    return OperResult<bool>.Succeed(false);
                default:
                    return OperResult<bool>.Failed("操作失败");
            }
        }
    }
}
